cmake_minimum_required(VERSION 3.0)

project(custom_command_example)

# Set static library to lib file
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Set dynamic library to lib file
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Set dynamic runtime library or exetuable file to bin file
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

add_executable(${PROJECT_NAME} test.cpp)

if (MSVC)
  file(GLOB config_file "${CMAKE_SOURCE_DIR}/config/*.txt")
  add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                     COMMAND ${CMAKE_COMMAND} -E copy_if_different
                     ${config_file}
                     $<TARGET_FILE_DIR:${PROJECT_NAME}>)
elseif(UNIX)
  file(GLOB config_file "${CMAKE_SOURCE_DIR}/config/*.txt")
  file(COPY ${config_file} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

